//
//  UIScrollView+BNAdd.m
//  CoralDemo
//
//  Created by kevin007 on 2021/4/25.
//

#import "UIScrollView+BNAdd.h"

@implementation UIScrollView (BNAdd)

- (void)bn_cancelDelaysContentTouches {
    self.delaysContentTouches = NO;
    for (UIView *subView in self.subviews) {
        if ([subView isKindOfClass:[self class]]) {
            ((UIScrollView *)subView).delaysContentTouches = NO;
        }
    }
}

- (void)bn_scrollToTopAnimated:(BOOL)animated {
    [self scrollRectToVisible:CGRectMake(0, 0 - self.contentInset.top, self.width, self.height) animated:animated];
}

- (void)bn_scrollToBottomAnimated:(BOOL)animated {
    [self scrollRectToVisible:CGRectMake(0, self.contentSize.height - self.bounds.size.height + self.contentInset.bottom, self.width, self.height) animated:animated];
}

- (void)bn_scrollToLeftAnimated:(BOOL)animated {
    [self scrollRectToVisible:CGRectMake(0 - self.contentInset.left, 0, self.width, self.height) animated:animated];
}

- (void)bn_scrollToRightAnimated:(BOOL)animated {
    [self scrollRectToVisible:CGRectMake(self.contentSize.width - self.bounds.size.width + self.contentInset.right, 0, self.width, self.height) animated:animated];
}

@end
